package com.yanqu.road.entity.drugstore;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_u_drug_store", desc = "药铺")
public class UserDrugStoreData extends DataObject {

    @FieldTypeAnnotation(update = true, select = true, desc = "玩家")
    private long userId;

    @FieldTypeAnnotation(desc = "药铺等级")
    private int drugStoreLv;

    @FieldTypeAnnotation(desc = "体力")
    private int power;

    @FieldTypeAnnotation(desc = "药铺经验")
    private long experience;

    @FieldTypeAnnotation(desc = "铜币")
    private long tongBi;

    @FieldTypeAnnotation(desc = "上次恢复时间")
    private long lastRecoverPowerTime;

    @FieldTypeAnnotation(desc = "账房先生-等级")
    private int bookKeeperLv;

    @FieldTypeAnnotation(desc = "药剂师-等级")
    private int druggistLv;

    @FieldTypeAnnotation(desc = "当前订单号")
    private long orderNo;

    @FieldTypeAnnotation(desc = "聚宝盆奖励")
    List<DrugOrderReward> rewardList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "当前种植工序id")
    private long plantId;

    @FieldTypeAnnotation(desc = "最大队列id")
    private long maxQueueId;

    @FieldTypeAnnotation(desc = "排队中的小人")
    List<DrugStoreQueue> npcQueueList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "背包药材数量")
    private Map<Integer, Integer> drugNumMap;

    @FieldTypeAnnotation(desc = "已解锁药材")
    private List<Integer> unLockDrug = new ArrayList<>();

    @FieldTypeAnnotation(desc = "已解锁诊桌/药师")
    private List<DrugStoreDoctorTable> doctorTableList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "最后退出界面的时间")
    private long lastQuitViewTime;

    @FieldTypeAnnotation(desc = "冲榜活动数据")
    private Map<Integer, DrugActivityRankValue> rankActivityDataMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "疑难杂症buff")
    private DrugStoreBuffValue buffValue = new DrugStoreBuffValue();

    @FieldTypeAnnotation(desc = "工艺")
    private List<DrugStoreTeach> techList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "接待病人数")
    private long receiveNum;

    @FieldTypeAnnotation(desc = "进入界面时间")
    private long entryViewTime;

    //缓存田地数量
    private int landNum;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public int getDrugStoreLv() {
        return drugStoreLv;
    }

    public void setDrugStoreLv(int drugStoreLv) {
        if(this.drugStoreLv != drugStoreLv) {
            this.drugStoreLv = drugStoreLv;
            setUpdateOption();
        }
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        if(this.power != power) {
            this.power = power;
            setUpdateOption();
        }
    }

    public long getExperience() {
        return experience;
    }

    public void setExperience(long experience) {
        if(this.experience != experience) {
            this.experience = experience;
            setUpdateOption();
        }
    }

    public long getTongBi() {
        return tongBi;
    }

    public void setTongBi(long tongBi) {
        if(this.tongBi != tongBi) {
            this.tongBi = tongBi;
            setUpdateOption();
        }
    }

    public long getLastRecoverPowerTime() {
        return lastRecoverPowerTime;
    }

    public void setLastRecoverPowerTime(long lastRecoverPowerTime) {
        if(this.lastRecoverPowerTime != lastRecoverPowerTime) {
            this.lastRecoverPowerTime = lastRecoverPowerTime;
            setUpdateOption();
        }
    }

    public int getBookKeeperLv() {
        return bookKeeperLv;
    }

    public void setBookKeeperLv(int bookKeeperLv) {
        if(this.bookKeeperLv != bookKeeperLv) {
            this.bookKeeperLv = bookKeeperLv;
            setUpdateOption();
        }
    }

    public int getDruggistLv() {
        return druggistLv;
    }

    public void setDruggistLv(int druggistLv) {
        if(this.druggistLv != druggistLv) {
            this.druggistLv = druggistLv;
            setUpdateOption();
        }
    }

    public long getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(long orderNo) {
        if(this.orderNo != orderNo) {
            this.orderNo = orderNo;
            setUpdateOption();
        }
    }

    public long getPlantId() {
        return plantId;
    }

    public void setPlantId(long plantId) {
        if(this.plantId != plantId) {
            this.plantId = plantId;
            setUpdateOption();
        }
    }

    public List<DrugOrderReward> getRewardList() {
        return rewardList;
    }

    public void setRewardList(List<DrugOrderReward> rewardList) {
        this.rewardList = rewardList;
        setUpdateOption();
    }

    public long getMaxQueueId() {
        return maxQueueId;
    }

    public void setMaxQueueId(long maxQueueId) {
        if(this.maxQueueId != maxQueueId) {
            this.maxQueueId = maxQueueId;
            setUpdateOption();
        }
    }

    public List<DrugStoreQueue> getNpcQueueList() {
        return npcQueueList;
    }

    public void setNpcQueueList(List<DrugStoreQueue> npcQueueList) {
        this.npcQueueList = npcQueueList;
        setUpdateOption();
    }

    public Map<Integer, Integer> getDrugNumMap() {
        return drugNumMap;
    }

    public void addDrugNum(int drugId, int num){
        int oldNum = drugNumMap.getOrDefault(drugId, 0);
        drugNumMap.put(drugId, oldNum + num);
        setUpdateOption();
    }

    public void subDrugNum(int drugId, int num){
        int oldNum = drugNumMap.getOrDefault(drugId, 0);
        if(oldNum > 0){
            drugNumMap.put(drugId, Math.max(0, oldNum - num));
            setUpdateOption();
        }
    }

    public int getDrugNum(int drugId){
        return drugNumMap.getOrDefault(drugId, 0);
    }

    public void setDrugNumMap(Map<Integer, Integer> drugNumMap) {
        this.drugNumMap = drugNumMap;
        setUpdateOption();
    }

    public List<Integer> getUnLockDrug() {
        return unLockDrug;
    }

    public void setUnLockDrug(List<Integer> unLockDrug) {
        this.unLockDrug = unLockDrug;
        setUpdateOption();
    }

    public void addUnLockDrug(int drugId){
        if(!unLockDrug.contains(drugId)){
            unLockDrug.add(drugId);
            setUpdateOption();
        }
    }

    public List<DrugStoreDoctorTable> getDoctorTableList() {
        return doctorTableList;
    }

    public void setDoctorTableList(List<DrugStoreDoctorTable> doctorTableList) {
        this.doctorTableList = doctorTableList;
        setUpdateOption();
    }

    public long getLastQuitViewTime() {
        return lastQuitViewTime;
    }

    public void setLastQuitViewTime(long lastQuitViewTime) {
        if(this.lastQuitViewTime != lastQuitViewTime) {
            this.lastQuitViewTime = lastQuitViewTime;
            setUpdateOption();
        }
    }

    public Map<Integer, DrugActivityRankValue> getRankActivityDataMap() {
        return rankActivityDataMap;
    }

    public void setRankActivityDataMap(Map<Integer, DrugActivityRankValue> rankActivityDataMap) {
        this.rankActivityDataMap = rankActivityDataMap;
        setUpdateOption();
    }

    public DrugStoreBuffValue getBuffValue() {
        return buffValue;
    }

    public void setBuffValue(DrugStoreBuffValue buffValue) {
        this.buffValue = buffValue;
        setUpdateOption();
    }

    public List<DrugStoreTeach> getTechList() {
        return techList;
    }

    public void setTechList(List<DrugStoreTeach> techList) {
        this.techList = techList;
        setUpdateOption();
    }

    public long getReceiveNum() {
        return receiveNum;
    }

    public void setReceiveNum(long receiveNum) {
        if(this.receiveNum != receiveNum) {
            this.receiveNum = receiveNum;
            setUpdateOption();
        }
    }

    public long getEntryViewTime() {
        return entryViewTime;
    }

    public void setEntryViewTime(long entryViewTime) {
        if(this.entryViewTime != entryViewTime) {
            this.entryViewTime = entryViewTime;
            setUpdateOption();
        }
    }

    //缓存
    public int getLandNum() {
        return landNum;
    }

    public void setLandNum(int landNum) {
        this.landNum = landNum;
    }
}
